* NOTE: if Stata does not do so automatically, cd to the top level directory of the data depository (where this script is stored)
* creates table S1: demographics by country

use data\maindata.dta, clear

replace confidence = confidence/100
gen reasons = 1 if !mi(judgmentreasons)
tab age, gen(age)
drop age
foreach v of varlist age* {
	local l`v' : variable label `v'
	}
collapse (count) guilty reasons sentence (mean) age* confidence knowICL recognize judge_appeals judge_criminal everprosecutor, by(country)
foreach v of varlist age* {
	label var `v' "`l`v''"
	}
label var country "Country"
label var guilty "N"
label var reasons "     with reasons"
label var sentence "     with sentence"
label var confidence "Confidence in decision"
label var knowICL "Prior knowledge of int'l criminal law"
label var recognize "Recognized names and places in the case"
label var judge_appeals "Appellate Judge"
label var judge_criminal "Criminal Judge"
label var everprosecutor "Former Prosecutor"

merge 1:1 country using data\USdemographics, update nogenerate

order country guilty reasons sentence judge* ever*  age* gender* know recogn confidence
export excel using tables\tableS1_sumstats.xlsx, firstrow(varlabels) replace